package algorithm.common;

import java.util.Scanner;

/**
 * @Author: Hevery
 * @Description:
 * @Date: Created on 2017/9/10
 * @Modified By:
 */
public class Main8 {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int []degree = new int[n+1];
        for(int i=1;i<degree.length;i++){
            degree[i]=scan.nextInt();
        }
        int q = scan.nextInt();
        int []res = new int[q];
        for(int j=0;j<q;j++){
            int l = scan.nextInt();
            int r = scan.nextInt();
            int k = scan.nextInt();
            int count = 0;
            for(int i=l;i<=r;i++){
                if(degree[i] == k){
                    count++;
                }
            }
            res[j]=count;
        }
        for(int i=0;i<res.length;i++){
            System.out.println(res[i]);
        }

    }

}
